﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace G28BS.Models
{
    public class RankingStats
    {
        public const int maxRank = 1000;
        public const int minRank = 0;
        public const int tttStartRank = 500;
        public const int fffStartRank = 500;
    }


    //public class Rank
    //{
    //    [Key, ForeignKey("userId")]
    //    public int rankingId {get; set; }
    //    public virtual UserProfile userId { get; set; }
    //    public int tttRank { get; set; }
    //    public int fffRank { get; set; }
    //    // Actually really simple table - refactor onto another table? Current solution will get more complex as gametypes added, maybe leave as is       
    //    public Rank(UserProfile rankedUser)
    //    {
    //        rankingId = rankedUser.UserId;
    //        tttRank = RankingStats.tttStartRank;
    //        fffRank = RankingStats.fffStartRank;
    //    }

    //    // This is the only constructor I'm using, really
    //    public Rank(string userName)
    //    {
    //        AppRepository repo = new AppRepository();

    //        this.rankingId = (from UserProfile in repo.userProfiles where UserProfile.UserName == userName select UserProfile.UserId).FirstOrDefault();

    //        this.tttRank = RankingStats.tttStartRank;
    //        this.fffRank = RankingStats.fffStartRank;

    //    }

    //    // Declare default constructor to allow LINQ queries ( requires a default constructor )
    //    public Rank()
    //    {

    //    }

    //    public void changeTTTRank(int rankChange)
    //    {
    //        AppRepository repo = new AppRepository();

    //        this.tttRank += rankChange;

    //        if (this.tttRank > RankingStats.maxRank)
    //        {
    //            this.tttRank = RankingStats.maxRank;
    //        }
    //        else if (this.tttRank < RankingStats.minRank)
    //        {
    //            this.tttRank = RankingStats.minRank;
    //        }

    //        // write this unto the database, this might even be more stupid than it appears:

    //        //Rank thisGuyRank = (from Rank in repo.ranks where Rank.rankingID == this.rankingID select Rank).FirstOrDefault();

    //        //repo.AddRank(thisGuyRank);

    //        repo.Save();
    //    }
    //}
}